<template>
	<view class="content">
		<text style="font-size: 40rpx; display: block; text-align: center;">子组件B</text>
		<view class="b-box" style="margin: 30rpx 30rpx; padding: 20rpx; background: #f5f5f5;">
			<text>compA组件传进来的值:</text>
			<text class="intent-text-box"
				style="font-weight: bold; color: #007AFF; margin-left: 10rpx;">{{ result }}</text>
		</view>
		<view class="b-box" style="margin: 0 30rpx; display: flex; align-items: center; gap: 20rpx;">
			<text>回传值:</text>
			<input type="text" v-model="callbackValue"
				style="color: brown; flex: 1; border: 1px solid #eee; padding: 15rpx;" />
			<button @click="sendOutside()" size="mini" type="warn">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				result: '',
				callbackValue: ''
			}
		},
		created() {
			uni.$on('getIntent', (msg) => {
				console.error("----CompB----getIntent----->" + msg);
				this.result = msg;
			});
		},
		methods: {
			sendOutside() {
				console.warn("----CompB----sendOutside------>" + this.callbackValue);
				this.$emit('callBackFun', this.callbackValue);
			}
		},
	}
</script>

<style scoped>
	.content {
		background: #fff;
		padding: 30rpx 0;
		margin: 0 30rpx;
	}
</style>